package pers.lx.crm.dao.info;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;
import pers.lx.crm.entiy.info.TagBlockDO;
import pers.lx.crm.entiy.info.TemplateDO;

import java.util.List;

/**
 * Created by lxl on 2017/2/28.
 */
@Repository
public interface TemplateDao {

    @Select("select* from template")
    public List<TemplateDO> selectTemplateListPage(TemplateDO templateDO) ;

    public void insertTemplate(TemplateDO templateDO) ;

    @Update("update template set name=#{name},description=#{description} where id=#{id}")
    public void updateTemplate(TemplateDO templateDO) ;

    @Insert("insert into template_info(template_id,tag_block_id) values(#{0},#{1})")
    public void insertTemplateInfo(int templateId, int tagBlockId) ;

    @Delete("delete from template where id=#{templateId}")
    public void deleteTemplate(int templateId) ;

    @Delete("delete from template_info where template_id=#{templateId}")
    public void deleteTemplateInfo(int templateId) ;

    @Select("select* from tag_block,template_info where tag_block.id = template_info.tag_block_id and template_info.template_id = #{templateId}")
    public List<TagBlockDO> selectTagBlocks(int templateId) ;

}
